package com.taxicalculator.ui;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.taxicalculator.dto.Faq;
/*
 * This Activity allows users to view recently asked questions and to submit their own via email to Tech Support
 */
public class FaqActivity extends Activity{

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                setContentView(R.layout.faqmain);

                
               
                // pass data to the custom adapter
                FaqAdapter adapter = new FaqAdapter(this, insertData());
         
                // Get ListView from faqmain.xml
                ListView listView = (ListView) findViewById(R.id.listViewFaq);
         
                // setListAdapter
                listView.setAdapter(adapter);
            }
         
            private ArrayList<Faq> insertData(){
                ArrayList<Faq> items = new ArrayList<Faq>();
                items.add(new Faq("What is MPG?","MPG is your Miles per gallon of gasoline. As in how many miles per gallon can a car travel with the engine running."));
                items.add(new Faq("How do I find out the gas Price?","You can lookup the gas prices at gas stations near you."));
                items.add(new Faq("Can I save my distance for the next time the app is opened?","Yes. Once you have entered a distance, it will be save the next time you open the app."));
                items.add(new Faq("How does the Taxi Calculator calculate cost?","the Taxi Calculator calculates the cost based on your destination, miles per gallon and gas cost."));
                
                return items;
            }

     

        //create a button intent for users to rate the app
        public void onrateClick(View v) {
            
            // make an intent that will display the results screen.
                            Intent ratingActivityIntent = new Intent(this, RatingActivity.class);
                    // go to the new intent.
                    startActivity(ratingActivityIntent);
            }
       
        /*
         * create an email Intent to allow users to email us questions
         * you must have email setup on your emulator for it to work properly
         */
        public void emailonClick(View e)
        {
      
    	Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    	String emailaddress[]={"taxicalcsupprtuc334@gmail.com"};
    	emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
    	emailIntent.putExtra(Intent.EXTRA_SUBJECT, "User Question");
    	emailIntent.setType("text/plain");
    	
    	startActivity(emailIntent);
        }}

